#
# @lc app=leetcode.cn id=3 lang=python3
#
# [3] 无重复字符的最长子串
#


# @lc code=start
class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        maxString = ''
        maxLength = 0
        for j in s:
            pos = maxString.find(j) + 1
            if pos:
                maxString = maxString[pos:] + j
            else:
                maxString += j
                maxLength = maxLength < len(maxString) and len(maxString) or maxLength
        return maxLength


# @lc code=end
